package com.qf.controller;/*
 *徐韬
 *2021/11/3
 *17:38
 */

import com.github.pagehelper.PageInfo;
import com.qf.dto.R;
import com.qf.pojo.TChannel;
import com.qf.service.channelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/channel")
@Api(tags = "通讯公司管理")
public class channelController {
    private channelService channelService;
@Autowired
    public void setChannelService(com.qf.service.channelService channelService) {
        this.channelService = channelService;
    }
    @GetMapping("/showAll")
    public R showAll(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "2") Integer pageSize ){
        PageInfo<TChannel> pageInfo = channelService.showAll(pageNum, pageSize);
        return R.setOk(pageInfo);
    }
    @PostMapping("/add")
    public R add(@RequestBody TChannel tChannel){
        channelService.addChannel(tChannel);
        return R.setOk();
    }
    @PostMapping("/update")
    public R update(@RequestBody TChannel tChannel){
    channelService.updateChannel(tChannel);
    return R.setOk();
    }
    @DeleteMapping("/delete")
    public R delete(@RequestBody Map map){
        List<Integer> ids =(List<Integer>) map.get("ids");
        channelService.deleteByids(ids);
        return R.setOk();
    }
}
